﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartHouseOOP
{
    public class Room
    {
        private int number;
        private string name;
        private List<Device> devices;
        public Room(int inputNumber, string inputName)
        {
            this.name = inputName;
            this.number = inputNumber;
            devices = new List<Device>();
        }
        public void AddOneDevice(Device currentDevice)
        {
            this.devices.Add(currentDevice);
        }
        //сюда передаем в параметр тип ресурса,чтобы не писать 3 идентичных метода и не дубл.код
        public List<Device> GetAllDevicesByType(Resource currentResource)
        {
            List<Device> devicesByType = new List<Device>();
            foreach (Device device in devices)
            {
                if (device.ResourceLabel == currentResource.ResourceLabel)
                {
                    devicesByType.Add(device);
                }
            }
            return devicesByType;
        }

        public override string ToString()
        {
            string status = string.Empty;
            status += "Room number:" + number + "\n";
            status += "Room name:" + name + "\n";
            status += "\tDevices:\n";
            foreach (Device device in devices)
            {
                status += device.ToString();
            }
            status += "##########################\n";
            //status += "Info about devices:" + name + "\n";
            return status;
        }
        //
    }
}
